<%-- 
    Document   : login
    Created on : 2020-5-27, 16:37:26
    Author     : Administrator
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="../js/jquery-3.4.1.min.js"></script>
        <link rel="stylesheet" href="../layui/css/mystyle.css"/>
        <title>登录界面</title>
        <style>
            body{
                background-image: url(../imgs/admin_bg1.jpg);
                background-size: 100% auto;
                background-repeat: no-repeat;
            }
        </style>
    </head>
    <body>
        <div class="box">
            <h1>社交画板后台管理</h1>
            <div class="login_form">
                <div class="title">
                    <h3>管理员登录</h3>
                    <br>
                </div>
                <form>
                    <div class="bar">
                        <img src="../imgs/name_f.png">
                        <input type="text" placeholder="用户名" id="name">
                    </div>
                    <div class="bar">
                        <img src="../imgs/pwd_f.png">
                        <input type="password" placeholder="密码" id="pwd">
                    </div>
                </form>
                <button type="button" id="login">登录</button>
            </div>
            <div class="layui-footer footer">
                Copyright @2020 事前诸葛亮
            </div>
        </div>

        <script>
            $(document).ready(function () {
                $("#login").click(function () {
                    $.ajax({
                        url: "manager/Login",
                        type: "POST",
                        data: {
                            username: $("#name").val(),
                            password: $("#pwd").val()
                        },
                        success: function (resp) {
                            if (resp.code === 200) {
                                window.location.href = "user_administrator.jsp";
                            } else {
                                alert("用户名或密码错误");
                            }
                        },
                        error: function (req, status, error) {
                            alert("错误,异常是：" + error);
                        }
                    })
                })
            })
        </script>
    </body>
</html>
